#ifndef QUEUE_H
#define QUEUE_H

#include <stdint.h>
#include <pthread.h>
#include <semaphore.h>

#if defined(__cplusplus)
extern "C" {
#endif

#define QUEUE_SIZE 10

typedef struct {
	union {
		struct {
			char cmd[32];
			char terminator[128];
			uint8_t ignoreNumLines;
			uint8_t expectedLines;
			uint8_t expectedTime;
		} rw;
    	char data[150];
	};
} QUEUE_ELEM;

typedef struct {
    QUEUE_ELEM *data;
    uint32_t data_size;
    uint32_t head;
    uint32_t elements; // might not need this...
    sem_t semaphore;
    pthread_mutex_t mutex;
} *QUEUE_HANDLE;

QUEUE_HANDLE init_queue();
int queue_push(QUEUE_HANDLE handle, QUEUE_ELEM *elem);
int queue_pop(QUEUE_HANDLE handle, QUEUE_ELEM *elem);

#if defined(__cplusplus)
}
#endif

#endif
